//
//  IndexNavViewController.m
//  CarTown
//
//  Created by 熊浩 on 15/8/1.
//  Copyright (c) 2015年 熊浩. All rights reserved.
//

#import "IndexNavViewController.h"
#import "SearchViewController.h"
#import "PersonalDetailViewController.h"
#import "CompanyDetailViewController.h"
@interface IndexNavViewController ()

@end

@implementation IndexNavViewController
+(instancetype)viewcontroller{
    IndexNavViewController *vc=[XHMianStory instantiateViewControllerWithIdentifier:@"index"];
    return vc;
}
- (UIViewController *)childViewControllerForStatusBarStyle{
    return self.topViewController;
}

- (UIStatusBarStyle)preferredStatusBarStyle
{
    return UIStatusBarStyleLightContent;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    [self setupNavBar:NO];

    // Do any additional setup after loading the view.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
-(void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated{
  
    
    if ([self respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
        self.interactivePopGestureRecognizer.delegate = nil;
    }
    
    [super pushViewController:viewController animated:animated];
    
    
    
//    UIButton *backbtn=[UIButton buttonWithType:UIButtonTypeCustom];
//    [backbtn setImage:[UIImage imageNamed:@"back_ico"] forState:UIControlStateNormal];
//    CGSize backsize=backbtn.currentImage.size;
//    backbtn.frame=CGRectMake(0, 0, backsize.width, backsize.height);
//    
//    [backbtn addTarget:self action:@selector(back) forControlEvents:UIControlEventTouchUpInside];
    viewController.navigationItem.leftBarButtonItem=[[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"back"] style:UIBarButtonItemStyleDone target:self action:@selector(back)];
    [self setupNavBar:NO];
    
}



-(void)setupNavBar:(BOOL)issearch{
    if (issearch) {
        [self.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor lightGrayColor]}
         ];
        [self.navigationBar setBackgroundImage:[UIImage imageNamed:@"whilte_navbg"] forBarMetrics:UIBarMetricsDefault];
        [self.navigationBar setTranslucent:YES];
        [self.navigationBar setTintColor:[[UIColor alloc]initWithRed:46/255.0 green:141/255.0 blue:215/255.0 alpha:1.0]];
    }else{
        [self.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor whiteColor]}
         ];
        [self.navigationBar setBackgroundImage:[UIImage imageNamed:@"navbg"] forBarMetrics:UIBarMetricsDefault];
        [self.navigationBar setTranslucent:YES];
        [self.navigationBar setTintColor:[UIColor whiteColor]];
    }
}
-(void)menu{
    
}
-(void)back{
    if ([self.viewControllers[self.viewControllers.count-1] isKindOfClass:[PersonalDetailViewController class]]||[self.viewControllers[self.viewControllers.count-1] isKindOfClass:[CompanyDetailViewController class]]) {
        [self setupNavBar:NO];
    }
    [self popViewControllerAnimated:YES];
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
